package javax;

/**
 * Created by xupeng20 on 2019/1/17.
 */
public class Xp_0121 {
    /**
     *去除单链表中重复元素，保留1个重复的元素。
     */
    class ListNode{
        int val;
        ListNode next;
        public ListNode(int x){
            val =x;
        }
    }
    public ListNode Dome(ListNode head){
        if (null == head){
            return head;
        }
        ListNode L1 = head;
        ListNode L2 = head.next;
        while (L2 != null) {
            if(L1.val == L2.val){
               L1.next = L2.next;
            }else {
                L1 = L2;
            }
        }
        return head;
    }
}
